The present invention relates to an image processing method and apparatus thereto for generating a mosaic image by combining a plurality of texture images.
Mosaic is widely known as xe2x80x9ca pattern produced by, or the technique of producing a pattern by combining small pieces of colored stone, glass, marble, etc., and fitting into a floor or wall or the like (Contemporary Japanese Dictionary, Sanseido).xe2x80x9d Employing this technique, a pattern or a photographic image can be formed with a combination of a plurality of photographic images.
By applying such mosaic technique to image data processing, it is possible to form a mosaic image by replacing an original image with a plurality of texture images (tile images). More specifically, plural types of texture images which are smaller than the original image are prepared in advance. By selecting and arranging appropriate images according to the original image, a mosaic image consisting of a plurality of texture images can be produced.
To generate a mosaic image, an original image is divided into a plurality of areas, and in each of the areas, a texture image which will construct the mosaic image is pasted. However, if the pasted texture image does not have a similar color to the corresponding area of the original image, the produced mosaic image will appear completely different from the original image, and also the image quality of the mosaic image deteriorates.
Moreover, in generation of a mosaic image, if a texture image includes an edge component, or if a divided area of the original image includes an edge component or special color distributions, it is difficult to perform proper color matching between the area and the texture image and the generated mosaic image is deteriorated.
Furthermore, in the above-described mosaic technique, it is necessary to prepare a sufficiently large number of colors and types of texture images to construct a mosaic image in general. However in reality, it is difficult to prepare an excessive amount of texture images as an image file in advance. Furthermore, in order to store such texture images in advance, an extremely large amount of storage is required, which results in cost increase, thus is not practical. Because of the above reasons, a sufficient number of texture images cannot be used when implementing the above-described mosaic technique. As a result, texture images which construct the mosaic image sometimes have far different colors and/or textures from those of respective areas of the original image, and the quality of a produced mosaic image is deteriorated.
The present invention is made in consideration of the above situation, and has as its object to provide an image processing method and apparatus for producing a mosaic image by combining texture images having similar colors to that of an original image.
Furthermore, another object of the present invention is to provide an image processing method and apparatus for diffusing density difference between a divided area of an original image and a texture image to peripheral areas of the area, so as to generate a mosaic image where density difference between the original image and an entire produced mosaic image is reduced.
Furthermore, another object of the present invention is to provide an image processing method and apparatus for producing a high-quality mosaic image while maintaining density characteristics of an original image.
Still further, another object of the present invention is to provide an image processing method and apparatus for producing a mosaic image where characteristics of an original image are best expressed, by further dividing divided areas (tile areas) of the original image into a plurality of segment areas, then dividing a texture image into a plurality of segment areas, and producing a mosaic image by using a texture image having a minimum total average density difference between the segment areas of the original image and the segment areas of the texture image, with respect to an area (tile area).
Moreover, another object of the present invention is to provide an image processing method and apparatus capable of producing a mosaic image based on an original image while maintaining characteristics of color distribution in the original image.
Still further, another object of the present invention is to provide an image processing method and apparatus capable of producing a mosaic image which best expresses a diversity of an original image by using a small number of texture images.
Furthermore, another object of the present invention is to provide an image processing method and apparatus for producing a mosaic image which is visually natural.
When comparing a divided area (tile area) of an original image with each texture image, average luminance or average density per pixel is calculated with respect to three primary colors: red (R), green (G) and blue (B) for each texture image and a divided area subjected to processing, and a texture image having a minimum difference in the average luminance or average density is selected as a texture image of the subject divided area.
Furthermore, an L*a*b* color space parameter is obtained for each texture image and a divided area subjected to processing, and a texture image having a minimum difference in the L*a*b* color space parameters is selected as a texture image of the subject divided area.
If an original image is a monochrome image and texture images are color images, texture image selection is performed based on average luminance or average density per pixel with respect to three primary colors R, G, and B for each texture image, while if an original image is a color image, texture image selection is performed based on the L*a*b* color space parameter.
According to the present invention, when a texture image for the subject divided area is selected as described above, a difference (error) in the average luminance or average density between the divided area and the selected texture image is calculated. The error is diffused to neighboring divided areas of the subject divided area. Based on the average luminance or average density of the neighboring divided area which has been updated by the error diffusion process, a texture image corresponding to each divided area is selected sequentially.
Furthermore, according to the present invention, in order to best express characteristics of an image included in each of the divided areas and texture images, the divided areas and texture images are further divided into a plurality of segment areas respectively, and average luminance or average density for each of R, G and B is obtained for each segment area of both the divided image and texture image. Then, a texture image having a minimum difference in the average luminance or average density for each color from a subject divided area is selected as a texture image of the subject divided area.
Moreover, according to the present invention, when a mosaic image is produced by selecting a texture image for each divided area as described above, a selected texture image of the produced mosaic image is modified by calculation based on a predetermined coefficient, the selected texture image and the corresponding divided area of the original image, then the modified texture image substitutes for the selected texture image. By this, a mosaic image which best expresses characteristics of the original image can be produced.
It is preferable that the value of the predetermined coefficient be changed by operation of an operator. Furthermore, the coefficient can automatically be obtained based on a color difference between the selected texture image and the corresponding divided area of the original image.
Other features and advantages of the present invention will be apparent from the following description taken in conjunction with the accompanying drawings, in which like reference characters designate the same or similar parts throughout the figures thereof.